import {BasicColumn} from '/@/components/Table';
import {FormSchema} from '/@/components/Table';
import { rules} from '/@/utils/helper/validator';
import { render } from '/@/utils/common/renderUtils';
//列表数据
export const columns: BasicColumn[] = [
  {
    title: '人员',
    align: "center",
    dataIndex: 'userId_dictText'
  },
  {
    title: '项目',
    align: "center",
    sorter: true,
    dataIndex: 'projectId_dictText'
  },
  {
    title: '项目经理',
    align: "center",
    sorter: true,
    dataIndex: 'pmId_dictText'
  },
  {
    title: '入项时间',
    align: "center",
    sorter: true,
    dataIndex: 'entryTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '离项时间',
    align: "center",
    sorter: true,
    dataIndex: 'departureTime',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '人员状态',
    align: "center",
    sorter: true,
    dataIndex: 'personnelStatus_dictText'
  },
  {
    title: '人员类型',
    align: "center",
    sorter: true,
    dataIndex: 'personnelStyle_dictText'
  },
  {
    title: '供应商',
    align: "center",
    sorter: true,
    dataIndex: 'supplier_dictText'
  },
  {
    title: '合同开始时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractStart',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '合同到期时间',
    align: "center",
    sorter: true,
    dataIndex: 'contractExpire',
    customRender:({text}) =>{
      return !text?"":(text.length>10?text.substr(0,10):text);
    },
  },
  {
    title: '提前提醒',
    align: "center",
    sorter: true,
    dataIndex: 'expireTipDay'
  },
  {
    title: '电话',
    align: "center",
    dataIndex: 'phone'
  },
  {
    title: '邮箱',
    align: "center",
    dataIndex: 'email'
  },
  {
    title: '通讯地址',
    align: "center",
    dataIndex: 'address'
  },
  {
    title: '创建人',
    align: "center",
    dataIndex: 'createBy'
  },
  {
    title: '创建时间',
    align: "center",
    dataIndex: 'createTime'
  },
  {
    title: '更新人',
    align: "center",
    dataIndex: 'updateBy'
  },
  {
    title: '更新时间',
    align: "center",
    dataIndex: 'updateTime'
  },
];

//查询数据
export const searchFormSchema: FormSchema[] = [
  {
    label: "人员",
    field: 'userId',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "项目",
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "项目经理",
    field: 'pmId',
    component: 'JSelectUser',
    //colProps: {span: 6},
  },
  {
    label: "入项时间",
    field: 'entryTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "离项时间",
    field: 'departureTime',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "人员状态",
    field: 'personnelStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "personnel_status"
    },
    //colProps: {span: 6},
  },
  {
    label: "人员类型",
    field: 'personnelStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "personnel_style"
    },
    //colProps: {span: 6},
  },
  {
    label: "供应商",
    field: 'supplier',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_supplier_manage,supplier_name,id"
    },
    //colProps: {span: 6},
  },
  {
    label: "合同开始时间",
    field: 'contractStart',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
  {
    label: "合同到期时间",
    field: 'contractExpire',
    component: 'DatePicker',
    //colProps: {span: 6},
  },
];

//表单数据
export const formSchema: FormSchema[] = [
  {
    label: '人员',
    field: 'userId',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入人员!'},
             ];
    },
  },
  {
    label: '项目',
    field: 'projectId',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_project,project_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目!'},
             ];
    },
  },
  {
    label: '项目经理',
    field: 'pmId',
    component: 'JSelectUser',
    componentProps:{
      labelKey: 'realname',
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入项目经理!'},
             ];
    },
  },
  {
    label: '入项时间',
    field: 'entryTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入入项时间!'},
             ];
    },
  },
  {
    label: '离项时间',
    field: 'departureTime',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入离项时间!'},
             ];
    },
  },
  {
    label: '人员状态',
    field: 'personnelStatus',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "personnel_status"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入人员状态!'},
             ];
    },
  },
  {
    label: '人员类型',
    field: 'personnelStyle',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "personnel_style"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入人员类型!'},
             ];
    },
  },
  {
    label: '供应商',
    field: 'supplier',
    component: 'JDictSelectTag',
    componentProps:{
      dictCode: "tm_supplier_manage,supplier_name,id"
    },
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入供应商!'},
             ];
    },
  },
  {
    label: '合同开始时间',
    field: 'contractStart',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同开始时间!'},
             ];
    },
  },
  {
    label: '合同到期时间',
    field: 'contractExpire',
    component: 'DatePicker',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入合同到期时间!'},
             ];
    },
  },
  {
    label: '提前提醒',
    field: 'expireTipDay',
    component: 'InputNumber',
    dynamicRules: ({model,schema}) => {
      return [
              { required: true, message: '请输入提前提醒!'},
             ];
    },
  },
  {
    label: '电话',
    field: 'phone',
    component: 'Input',
  },
  {
    label: '邮箱',
    field: 'email',
    component: 'Input',
  },
  {
    label: '通讯地址',
    field: 'address',
    component: 'Input',
  },
	// TODO 主键隐藏字段，目前写死为ID
  {
    label: '',
    field: 'id',
    component: 'Input',
    show: false,
  },
];

// 高级查询数据
export const superQuerySchema = {
  userId: {title: '人员',order: 0,view: 'sel_user', type: 'string',},
  projectId: {title: '项目',order: 1,view: 'list', type: 'string',dictTable: "tm_project", dictCode: 'id', dictText: 'project_name',},
  pmId: {title: '项目经理',order: 2,view: 'sel_user', type: 'string',},
  entryTime: {title: '入项时间',order: 3,view: 'date', type: 'string',},
  departureTime: {title: '离项时间',order: 4,view: 'date', type: 'string',},
  personnelStatus: {title: '人员状态',order: 5,view: 'list', type: 'string',dictCode: 'personnel_status',},
  personnelStyle: {title: '人员类型',order: 6,view: 'list', type: 'string',dictCode: 'personnel_style',},
  supplier: {title: '供应商',order: 7,view: 'list', type: 'string',dictTable: "tm_supplier_manage", dictCode: 'id', dictText: 'supplier_name',},
  contractStart: {title: '合同开始时间',order: 8,view: 'date', type: 'string',},
  contractExpire: {title: '合同到期时间',order: 9,view: 'date', type: 'string',},
  expireTipDay: {title: '提前提醒',order: 10,view: 'number', type: 'number',},
  phone: {title: '电话',order: 11,view: 'text', type: 'string',},
  email: {title: '邮箱',order: 12,view: 'text', type: 'string',},
  address: {title: '通讯地址',order: 13,view: 'text', type: 'string',},
  createBy: {title: '创建人',order: 14,view: 'text', type: 'string',},
  createTime: {title: '创建时间',order: 15,view: 'datetime', type: 'string',},
  updateBy: {title: '更新人',order: 16,view: 'text', type: 'string',},
  updateTime: {title: '更新时间',order: 17,view: 'datetime', type: 'string',},
};
